package luogu;

import java.util.Scanner;

public class test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        int k = sc.nextInt();
        int d = c;
        while (d >= k) {
            int c1 = d / k;
            c += c1;
            d = c1 + (d % k);
        }
        System.out.println(c);
    }
}
